# -*- coding: utf-8 -*-
# @File     : permissions.py
# @Author   : bingjia
# @Time     : 2020/7/27 16:18
# @Desc     : 用户权限

from ..base.api.permissions import AllowAny
from ..base.api.permissions import IsSuperUser
from ..base.api.permissions import IsAuthenticated
from ..base.api.permissions import BasePermission, IsObjUser


class UserPermission(BasePermission):
    # 全局权限
    global_perms = None
    enough_perms = IsSuperUser()

    # 增删改查
    list_perms = AllowAny()
    retrieve_perms = AllowAny()
    update_perms = IsObjUser()
    destroy_perms = IsObjUser()
    partial_update_perms = IsObjUser()

    # 头像、密码
    by_pk_perms = IsAuthenticated()
    by_username_perms = IsAuthenticated()
    password_recovery_perms = AllowAny()
    change_avatar_perms = IsAuthenticated()
    change_password_perms = IsAuthenticated()
    change_password_from_recovery_perms = AllowAny()


class UserMessagePermission(BasePermission):
    """
    用户消息权限
    """
    # 增删查
    list_perms = IsAuthenticated()
    create_perms = IsAuthenticated()
    destroy_perms = IsAuthenticated()
    retrieve_perms = IsAuthenticated()

    # 删除、已读
    all_read_perms = IsAuthenticated()
    all_delete_perms = IsAuthenticated()


class UserAdminPermission(BasePermission):
    """
    后台用户资源权限
    """
    # 全局权限
    global_perms = None
    enough_perms = IsSuperUser()

    # 增删改查
    list_perms = AllowAny()
    create_perms = IsSuperUser()





